package com.lsm.comet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.catalina.CometEvent;
import org.apache.catalina.CometProcessor;

/**
 * Servlet implementation class CometServlet
 */
public class CometServlet extends HttpServlet implements CometProcessor {

	public void event(CometEvent event) throws IOException, ServletException {
		HttpServletRequest request = event.getHttpServletRequest();
		HttpServletResponse response = event.getHttpServletResponse();
		if (event.getEventType() == CometEvent.EventType.BEGIN) {
			PrintWriter out = response.getWriter();
			out.write("Hello world");
			out.flush();
		} else if (event.getEventType() == CometEvent.EventType.ERROR) {
		} else if (event.getEventType() == CometEvent.EventType.END) {
		} else if (event.getEventType() == CometEvent.EventType.READ) {
		}
	}

	// protected void doGet(HttpServletRequest req, HttpServletResponse resp)
	// throws ServletException, IOException {
	// System.out.println("invoker servlet....");
	// }

}
